//
//  CustomPickerBottomView.m
//  CCBbelefitLife
//
//  Created by liurg on 16/1/3.
//  Copyright © 2016年 liurg. All rights reserved.
//

#import "CustomPickerBottomView.h"

@implementation CustomPickerBottomView

-(id)initWithFrame:(CGRect)frame titleArr:(NSArray *)titleArr{
    self = [super initWithFrame:frame];
    if (self)
    {
        _maskView = [[MaskView alloc]init];
        // NSArray *titleArr = @[@"完成",@"重录",@"退出",@"取消"];
        for (int i = 0; i<titleArr.count; i++) {
            UIView *cellView = [[UIView alloc]initWithFrame:CGRectMake(0, i*60, mainScreenWidth, 60)];
            [self addSubview:cellView];
            cellView.backgroundColor = [UIColor blackColor];
            UILabel *titleLab = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, mainScreenWidth, 20)];
            titleLab.text = titleArr[i];
            titleLab.textAlignment = NSTextAlignmentCenter;
            titleLab.textColor = [UIColor whiteColor];
            [cellView addSubview:titleLab];
            UIButton *viewBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, cellView.width, cellView.height)];
            [cellView addSubview:viewBtn];
            viewBtn.tag = 100+i;
            [viewBtn addTarget:self action:@selector(CustomPickerBottomSelect:) forControlEvents:UIControlEventTouchUpInside];
            viewBtn.backgroundColor = [UIColor clearColor];
            if (i!=titleArr.count-1) {
                UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(5, cellView.height-1, mainScreenWidth-5*2,1)];
                [cellView addSubview:lineView];
                lineView.backgroundColor = [UIColor whiteColor];
            }
        }
        
    }
    self.backgroundColor = [UIColor blackColor];
    [_maskView addSubview:self];
    [_maskView show];
    
    return self;
}


-(void)CustomPickerBottomSelect:(UIButton *)pickerBtn{
    
    [_maskView removeFromSuperview];
    if (self.delegate && [self.delegate respondsToSelector:@selector(CustomPickerBottomSelect:)]) {
        [self.delegate CustomPickerBottomSelect:pickerBtn];
    }
    
}


@end
